package api

import (
	"github.com/emicklei/go-restful/v3"
	"github.com/infraboard/mcube/http/response"

	"gitee.com/go-course/go8/projects/devcloud/cmdb/apps/resource"
)

func (h *handler) QueryResource(r *restful.Request, w *restful.Response) {
	req := resource.NewQueryResourceRequestFromHTTP(r.Request)
	set, err := h.service.QueryResource(r.Request.Context(), req)
	if err != nil {
		response.Failed(w.ResponseWriter, err)
		return
	}
	response.Success(w.ResponseWriter, set)
}
